package com.moonshineproject.plugin.menu.vo
{
	import com.moonshineproject.plugin.menu.interfaces.ICustomMenu;
	import com.moonshineproject.plugin.menu.interfaces.ICustomMenuItem;
	import com.moonshineproject.plugin.menu.interfaces.IMenuEntity;
	import com.moonshineproject.vo.KeyboardShortcut;
	

	

	public class CustomMenuItem  implements ICustomMenuItem, IMenuEntity
	{


		
		public function hasSubmenu():Boolean
		{
			return _data is ICustomMenu && (_data as ICustomMenu).items.length;
		}

		


		public function CustomMenuItem(label:String = "", isSeparator:Boolean = false, options:Object = null)
		{
			super();
			this.label = label;
			_isSeparator = isSeparator;
			init(options);
			
			

		}

		private function init(options:Object):void
		{
			if (options)
			{
				if (options.shortcut && options.shortcut.event && options.shortcut.key)
				{

					shortcut = new KeyboardShortcut(options.shortcut.event,options.shortcut.key, options.shortcut.mod);

				}
				if(options.data){
					data = options.data;
				}

				
			}
		}

		/* INTERFACE com.moonshineproject.plugin.menu.interfaces.ICustomMenuItem */

		public function get checked():Boolean
		{
			return false;
		}

		public function set checked(value:Boolean):void
		{

		}

		private var _data:Object

		public function get data():Object
		{
			return _data;
		}

		public function set data(value:Object):void
		{
			_data = value;
		}
		private var _isSeparator:Boolean
		public function get isSeparator():Boolean
		{
			return _isSeparator;
		}

		private var _shortcut:KeyboardShortcut

		public function get shortcut():KeyboardShortcut
		{
			return _shortcut;
		}

		public function set shortcut(value:KeyboardShortcut):void
		{
			if (_shortcut == value)
				return;
			_shortcut = value;
		
		}


		public function get submenu():ICustomMenu
		{
			if (!data)
				return null;
			return data as ICustomMenu
		}

		public function set submenu(value:ICustomMenu):void
		{
			if (data == value)
				return;

			data = value;

		}

		
		private var _label:String;
		public function get label():String
		{
			return _label;
		}

		public function set label(value:String):void
		{
			_label = value;

		}

		


	}
}